package examples.shootist;

import javax.sip.*;
import javax.sip.address.*;
import javax.sip.message.*;

import java.util.*;

public class MyRouter implements Router
{
	protected SipStack myStack;
	protected HopImpl defaultRoute;

	public MyRouter(SipStack sipStack, String nextHop)
	{

		this.myStack = sipStack;
		this.defaultRoute = new HopImpl(nextHop);
	}

	/**
	 * Always send requests to the default route location.
	 */
	public ListIterator<HopImpl> getNextHops(Request sipRequest)
	{
		LinkedList<HopImpl> ll = null;
		if (defaultRoute != null)
		{
			if (ll == null)
				ll = new LinkedList<HopImpl>();
			ll.add(defaultRoute);
			return ll.listIterator();
		}
		else
			return null;
	}

	public Hop getOutboundProxy()
	{
		return this.defaultRoute;
	}

	@Override
	public Hop getNextHop(Request arg0) throws SipException
	{
		return defaultRoute;
	}
}
